package com.jia.together.controller.front;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jia.together.entity.Guide;
import com.jia.together.service.GuideService;
import com.jia.together.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/front/guide")
//@CrossOrigin
public class GuideFrontController {

    @Autowired
    private GuideService guideService;
    @GetMapping("/queryList")
    public R queryList(@RequestParam(required = false) Integer recommend,@RequestParam(required = false) String type){
        QueryWrapper<Guide> wrapper = new QueryWrapper<>();
        if (!StringUtils.isEmpty(recommend)){
            wrapper.eq("recommend",1);
        }
        if (!StringUtils.isEmpty(type)){
            wrapper.eq("type",type);
        }
        wrapper.orderByAsc("sort");
        List<Guide> list = guideService.list(wrapper);
        return R.ok().data("data",list);
    }
}
